package org.example.controller;

import cn.hutool.json.JSONUtil;
import org.example.utils.RedisUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/add")
    public String add() {
        RedisUtils.setCacheObject("huhao", "1234567890");
        return "success";
    }

    @GetMapping("/get")
    public String get() {
        return RedisUtils.getCacheObject("huhao");
    }

    @GetMapping("/delete")
    public String delete() {
        return RedisUtils.deleteObject("huhao")?"success":"fail";
    }

    @GetMapping("/keys")
    public String keys() {
        return JSONUtil.toJsonStr(RedisUtils.keys("huhao"));
    }
}
